package main

/*
变量初始化的四种方式
*/

import (
	"fmt"
)

var gA int = 100
var gB = "gbbbb"
// gc := 200 方式四不能用于声明全局变量

func main() {
	// 方式一：只声明
	var a int
	fmt.Println("a = ", a)
	fmt.Printf("type of a = %T\n", a)

	// 方式二：声明并初始化
	var b int = 100
	fmt.Println("b = ", b)
	fmt.Printf("type of b = %T\n", b)
	
	var bb string = "abcd"
	fmt.Println("bb = ", bb)
	fmt.Printf("type of bb = %T\n", bb)

	// 方式三：省去变量类型
	var c = 100
	fmt.Println("c = ", c)
	fmt.Printf("type of c = %T\n", c)

	var cc = 1.234
	fmt.Println("cc = ", c)
	fmt.Printf("type of cc = %T\n", cc)

	// 方式四：省去var关键字
	d := 3.14
	fmt.Println("d = ", d)
	fmt.Printf("type of d = %T\n", d)
	e := "eeee"
	fmt.Println("e = ", e)
	fmt.Printf("type of e = %T\n", e)

	// 全局变量
	fmt.Println("gA = ", gA)
	fmt.Println("gB = ", gB)
	// fmt.Println("gc = ", gc)

	// 声明多个变量
	var xx, yy int = 100, 200
	fmt.Println("xx = ", xx, "yy = ", yy)

	var kk, ll = 100, "abcd"
	fmt.Println("kk = ", kk, "ll = ", ll)

	var (
		vv int = 100
		ww bool = true
	)
	fmt.Println("vv = ", vv, "ww = ", ww)
}